package UIFree.graphicTools.color.palettes
{
	import UIFree.uif_component;
	import UIFree.uif_ecomponent;
	
	import UIUtils.uif_color;
	
	import flash.display.BitmapData;
	import flash.geom.Rectangle;
	
	public class uif_spectrumPaletteView extends uif_basePaletteView {
		public function uif_spectrumPaletteView(parent:uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, styleClass:Object='') {
			super(parent, ax, ay, awidth, aheight, styleClass);
		}
		
		override public function get stepSize(): Number {
			return width / 30;
		}
		
		override protected function drawPalette(a_bmd: BitmapData): void {
			var r: Rectangle = new Rectangle(0, 0, stepSize, a_bmd.height);
				function ccos(i: Number): uint {
					var c: Number = (Math.cos(i * Math.PI * 2) + 1) / 2;
					//c = Math.pow(c, 1.5);
					return Math.floor(c * 0xFF);
				}
				
				while (r.x < a_bmd.width) {
					var i: Number = r.x / a_bmd.width;
					var color: uint = uif_color.RGB(ccos(i),
													ccos(i + 1/3 * 2),
													ccos(i + 1/3));
					a_bmd.fillRect(r, color);
					r.x += r.width;
				}
				r.y += r.height;
		}		
	}
}